let { conMysql } = require("../mysql");
const { dateTime } = require("../utils/dateTime");
async function add(req, res) {
  console.log("req: ", req);

  let add_info = { ...req.body };
  add_info.create_time = dateTime();
  let add_sql = `insert into banner set title='${add_info.title}',content='${add_info.content}',banner_url='${add_info.banner_url}',create_time='${add_info.create_time}',u_id='${req.user_info.id}'`;
  let add_result = await conMysql(add_sql);

  if (add_result) {
    res.success("添加成功");
  } else {
    res.err("添加失败");
  }
}
module.exports = { add };
